package flowdroid;

import cli.ConfigManager;

import java.io.IOException;
import java.io.PrintStream;
//import flowdroid.MyPreAnalysisHandler;

public class TestPipeline {
    static void test() throws Exception {
        // 1. 初始化变量
        String apkFileLocation = "/home/fyl/project/code/AndroPrivacyConsistency/data/apk/RQ2/SimpleMobileTools-file-manager-fdroid-6.16.1.apk";
        String androidJarPlatform = "/home/fyl/project/code/AndroPrivacyConsistency/libs/platforms";
        String sourceAndSinksPath = "";
        String callbacks = "";
        String dumpDir = "/home/fyl/project/code/AndroPrivacyConsistency/data/dump";
        String sourcePath = "/home/fyl/project/code/AndroPrivacyConsistency/data/source.txt";
        String sinkPath = "/home/fyl/project/code/AndroPrivacyConsistency/data/sink.txt";
        String pathToDataOnotology = "/home/fyl/project/code/AndroPrivacyConsistency/data/ontology/data_ontology.yml";
        String pathToEntityOntology = "/home/fyl/project/code/AndroPrivacyConsistency/data/ontology/entity_ontology.yml";
        String pathToPermissionStrings = "/home/fyl/project/code/AndroPrivacyConsistency/data/ontology/PermissionStrings.txt";
        String pathToPermissionMethods = "/home/fyl/project/code/AndroPrivacyConsistency/data/ontology/pathToPermissionMethods.txt";
        ConfigManager instance = ConfigManager.getInstanceWithParams(
                androidJarPlatform,
                "",
                "",
                sourcePath,
                sinkPath,
                pathToDataOnotology,
                pathToEntityOntology,
                pathToPermissionStrings,
                pathToPermissionMethods
        );

        try {
            String outFile = dumpDir + "/test.out";
            // 添加 PrintStream 字段
            PrintStream fileOut = new PrintStream(outFile);
            System.setOut(fileOut); // 重定向 System.out 到文件
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        Pipeline.pipeline(apkFileLocation, instance, dumpDir);
    }


    public static void main(String[] args) {
        try {
            test();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
